﻿using System;
using System.Text;

namespace Bbm.Persistence
{
	public class CacheContext
	{
		readonly CacheConfiguration config;

		public CacheContext(CacheConfiguration config)
		{
			this.config = config;
		}

		public CacheStore<T> Access<T>()
		{
			return Access<T>(null);
		}

		public CacheStore<T> Access<T>(string domain)
		{
			return new CacheStore<T>(
				config.StoreFactory.GetStoreForName(config.NameFactory.GetNameForStore(null, typeof (T), domain)),
				config.SerializationStrategy);
		}
	}
}
